import 'package:flutter/material.dart';
import 'package:qunaimedical/utils/common_util.dart';

typedef Callback<T> = void Function(T value);

/// 用户类型选择器
class UserTypeSelector extends StatefulWidget {
  final String? type;
  final Callback<String> callback;

  const UserTypeSelector({
    Key? key,
    required this.type,
    required this.callback,
  }) : super(key: key);

  @override
  _UserTypeSelectorState createState() => _UserTypeSelectorState();
}

class _UserTypeSelectorState extends State<UserTypeSelector> {
  late String type;

  @override
  void initState() {
    super.initState();
    type = widget.type ?? "doctor";
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        CommonUtil.hideKeyboard(context);
        _pick();
      },
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Container(
            margin: EdgeInsets.only(top: 16),
            child: Text(
              "用户类型",
              style: const TextStyle(fontSize: 16),
            ),
          ),
          Padding(
            padding: const EdgeInsets.symmetric(vertical: 16.0),
            child: Row(
              children: [
                Expanded(
                  child: Text(
                    "医生",
                    style: const TextStyle(fontSize: 16),
                  ),
                ),
                Container(
                  child: Icon(
                    Icons.keyboard_arrow_down,
                    color: Colors.grey,
                  ),
                  margin: EdgeInsets.only(right: 8),
                ),
              ],
            ),
          ),
          Container(
            color: Colors.grey[300],
            height: 1,
          ),
        ],
      ),
    );
  }

  void _pick() {
    //   CommonUtil.showPicker(
    //     context,
    //     pickerData: S.of(context).profileGenderMap!.values.toList(),
    //     onConfirm: (Picker picker, List value) {
    //       widget.callback(
    //           S.of(context).profileGenderMap!.keys.toList()[value.first]);
    //       type = S.of(context).profileGenderMap!.keys.toList()[value.first];
    //     },
    //     selectedIndex: [type == 'male' ? 0 : 1],
    //   );
    // }
  }
}
